﻿using MqLibrary;
using RabbitMqService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace AvatarWeb.Controllers
{
    public class TestController : Controller
    {       
        public TestController()
        {
           // cs = new RabbitHelper<T>();          
        }
        //
        // GET: /Test/      
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult InsertQuene()
        {   
            RabbitHelper<EmailModel> cs = new RabbitHelper<EmailModel>();
            EmailModel em = new EmailModel();
            em.FromAddress = "changjianguo@163.com";
            em.SendAddress = "528957877@qq.com";
            em.EmailTitle = "我在测试呢";
            em.EmailBody = "<a href = 'www.baidu.com'>www.baidu.com<a> <b>sss</b>" ;

            




                                                                                                                                         em.EmailType = ModelType.Notice;
            cs.InsertRabbitMq(RabbitTypeEnum.Email, em);
            ViewBag.message = "插入成功";
            return View("Index");
        }
        public ActionResult GetQuene()
        {
            RabbitHelper<EmailModel> cs = new RabbitHelper<EmailModel>();
            EmailModel result = cs.GetRabbitMq(RabbitTypeEnum.Email);
            JavaScriptSerializer js = new JavaScriptSerializer();
            ViewBag.message = js.Serialize(result);
            return View("Index");
        }
        public ActionResult InsertMeQuene()
        {
            RabbitHelper<ShortMessageModel> cs = new RabbitHelper<ShortMessageModel>();
            ShortMessageModel em = new ShortMessageModel();
            em.FromAddress = "13472444100";
            em.SendAddress = "13472444110";          
            em.MessageBody = "恭喜你成为亿万富翁";
            em.MessageType = ModelType.Notice;
            cs.InsertRabbitMq(RabbitTypeEnum.Message, em);
            ViewBag.message = "插入成功";
            return View("Index");
        }
        public ActionResult GetMeQuene()
        {
            RabbitHelper<ShortMessageModel> cs = new RabbitHelper<ShortMessageModel>();
            ShortMessageModel result = cs.GetRabbitMq(RabbitTypeEnum.Message);
            JavaScriptSerializer js = new JavaScriptSerializer();
            ViewBag.message = js.Serialize(result);
            return View("Index");
        }
    }
}
